package com.wyp168.leetcode;

import com.wyp168.leetcode.entity.Fruit;

import java.util.*;

public class Strstr {

    public static void main(String[] args) {

//        List<String> list = new ArrayList<>();
//        list.add("张三");
//        list.add("李四");
//        list.add("王五");
//        list.add("赵六");
//        List<String> result = list.stream().filter(x -> x.equals("张三")).collect(Collectors.toList());
//        System.out.println(result);

        List<Fruit> list = new ArrayList<>();
        list.add(new Fruit("apple",50));
        list.add(new Fruit("orange",25));
        list.add(new Fruit("banana",30));
        Iterator<Fruit> iterator = list.iterator();

        while (iterator.hasNext()) {
            Fruit fruit = iterator.next();
            if (fruit.getName().equals("apple") || fruit.getName().equals("orange"))
                iterator.remove();
        }

        System.out.println(list);

//        List<String> lsa = new ArrayList<>();
//        lsa.add("zhangsan");
//        lsa.add("lisi");
//        lsa.add("wangwu");
//        List<String> lsb = new ArrayList<>();
//        lsb.addAll(lsa);
//        System.out.println(lsb);
    }

    public static int strStr(String haystack, String needle) {
        char[] hc = haystack.toCharArray();
        char[] nc = needle.toCharArray();
        int isContainer = -1;
        if (nc.length > hc.length) {
            return isContainer;
        }
        return 0;
    }
}
